const { Router } = require('express');
const testService = require('../service/test');

class TestController {
  testService;
  async init() {
    this.testService = await testService();

    const router = new Router();
    router.get('/', this.getAll);

    return router;
  }

  getAll = async (req, res) => {
    const { pageIndex, pageSize } = req.query;
    const shopList = await this.testService.find({ pageSize, pageIndex });

    res.send({
      code: 0,
      data: shopList,
      message: 'OK'
    });
  }
}

module.exports = async function() {
  const c = new TestController();
  return await c.init();
}